<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/3/31
 * Time: 16:51
 */
namespace App\WebSocketController;

use App\Model\User;

class Controller
{
    public function onOpen($server, $request)
    {
        var_dump($request->fd);
        $server->push($request->fd, "hello, welcome\n");
    }

    public function onMessage($server, $frame)
    {
//        $user = User::all()->toArray();
        echo "id : {$frame->fd} Message: {$frame->data}\n";
        $server->push(2, 'fuck you');
    }

    public function onClose($server, $fd)
    {
        echo "client-{$fd} is closed\n";
    }
}